import { defineStore } from 'pinia'
import { accountRegisterRequest, sendEmailCode, updatePassword, verifyExist } from '@/service/register.js'

const useRegisterStore = defineStore('register', {
	state: () => ({
		name: '',
		password: ''
	}),
	actions: {
		async registerAccountAction(info) {
			const res = await accountRegisterRequest(info)
			this.name = info.name
			this.password = info.password
			return res
		},
		async sendEmailCodeAction(email) {
			const res = await sendEmailCode(email)
			return res
		},
		async verifyExistAction(data) {
			console.log(data, 123);
			const res = await verifyExist(data)
			return res
		},
		async updatePasswordAction(data) {
			const res = await updatePassword(data)
			return res
		}
	}
})

export default useRegisterStore
